package com.gp.study.tomcat.servlet;

import com.gp.study.tomcat.http.GPHttpMethod;
import com.gp.study.tomcat.http.GPHttpServletRequest;
import com.gp.study.tomcat.http.GPHttpServletResponse;

public abstract class GPDefaultServlet implements GpServlet {

	@Override
	public void doService(GPHttpServletRequest servletRequest, GPHttpServletResponse servletResponse) throws Exception {
		if(GPHttpMethod.GET.toString().equals(servletRequest.getMethod())){
			 doGet(servletRequest,servletResponse);
		}else if(GPHttpMethod.POST.toString().equals(servletRequest.getMethod())){
			 doPost(servletRequest,servletResponse);
		}else{
			throw new RuntimeException("not support req method find");
		}
		
	}
	
	// 必须声明为public 不能默认，否则，子类无法重写
	public abstract void doGet(GPHttpServletRequest servletRequest, GPHttpServletResponse servletResponse)throws Exception;
	
	public abstract void doPost(GPHttpServletRequest servletRequest, GPHttpServletResponse servletResponse)throws Exception;

}
